package com.example.mybatis.mapper;

import com.example.mybatis.model.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserInfoMapper2 {
    @Select("select * from userinfo where id = #{id}")
    List<UserInfo> getUserInfoById1(Integer id);

    @Select("select * from userinfo where id = ${id}")
    List<UserInfo> getUserInfoById2(Integer id);

    @Select("select * from userinfo where username = #{name}")
    List<UserInfo> getUserInfoByName1(String name);

    @Select("select * from userinfo where username = '${name}'")
    List<UserInfo> getUserInfoByName2(String name);

    @Select("select * from userinfo where username = #{name}")
    List<UserInfo> getUserInfoByName3(String name);

    @Select("select * from userinfo where username = '${name}'")
    List<UserInfo> getUserInfoByName4(String name);

    @Select("select * from userinfo order by id #{sort}")
    List<UserInfo> getUserInfoSort1(String sort);

    @Select("select * from userinfo order by id ${sort}")
    List<UserInfo> getUserInfoSort2(String sort);

    @Select("select * from userinfo where username like '%#{param}%'")
    List<UserInfo> getUserInfoLike1(String param);

    @Select("select * from userinfo where username like '%${param}%'")
    List<UserInfo> getUserInfoLike2(String param);

    @Select("select * from userinfo where username like concat('%',#{key},'%')")
    List<UserInfo> getUserInfoLike3(String param);
}
